/*
 * @Author: xiaoyang
 * @Date: 2021-04-28 11:11:56
 * @LastEditors: xiaoyang
 * @LastEditTime: 2021-04-29 17:10:28
 * @FilePath: \ruoyi-uif:\program_code\move_bzypt\main\js\result.js
 * @description: No description
 */
new Vue({
  el: '#result',
  data: {
    tabActive: 0,
    desc: {},
    s: {},
    a: {},
  },
  methods: {
    /**
     * @description: 查看月供详情
     * @param {*}
     * @return {*}
     */
    viewDetails() {
      window.location.href = `../../view-detail.html?active=${this.tabActive}&type=${getQueryVariable('type')}`;
    },

    /**
     * @description: tab 切换时触发
     * @param {*}
     * @return {*}
     */
    tabChagne(active) {
      let loan = JSON.parse(localStorage.getItem('loan') || null);
      let type = getQueryVariable('type');
      if (type != 3) {
        this.desc = loan[active];
      } else {
        this.desc = {
          loanTotalPrice: loan['a'][active].loanTotalPrice + loan['s'][active].loanTotalPrice,
          interestTotal: loan['a'][active].interestTotal + loan['s'][active].interestTotal,
          totalPrice: loan['a'][active].totalPrice + loan['s'][active].totalPrice,
        };

        // console.log(loan['s'][this.active]['list'][0].everyMonthPrice);
        this.s = {
          e_money: loan['s'][active]['list'][0].everyMonthPrice,
          loanTotalPrice: loan['s'][active].loanTotalPrice,
          tl: loan['s'][active].tl,
          totalPrice: loan['s'][active].totalPrice,
          interestTotal: loan['s'][active].interestTotal,
        };

        this.a = {
          e_money: loan['a'][active]['list'][0].everyMonthPrice,
          loanTotalPrice: loan['a'][active].loanTotalPrice,
          tl: loan['a'][active].tl,
          totalPrice: loan['a'][active].totalPrice,
          interestTotal: loan['a'][active].interestTotal,
        };
      }
    },
  },

  computed: {
    isMultiple() {
      let type = getQueryVariable('type');
      if (type == 3) {
        return true;
      }
      return false;
    },
  },

  mounted() {
    let type = getQueryVariable('type');
    let loan = JSON.parse(localStorage.getItem('loan') || null);
    if (type != 3) {
      this.desc = loan[this.tabActive];
    } else {
      this.desc = {
        loanTotalPrice: loan['a'][this.tabActive].loanTotalPrice + loan['s'][this.tabActive].loanTotalPrice,
        interestTotal: loan['a'][this.tabActive].interestTotal + loan['s'][this.tabActive].interestTotal,
        totalPrice: loan['a'][this.tabActive].totalPrice + loan['s'][this.tabActive].totalPrice,
      };

      this.s = {
        e_money: loan['s'][this.tabActive]['list'][0].everyMonthPrice,
        loanTotalPrice: loan['s'][this.tabActive].loanTotalPrice,
        tl: loan['s'][this.tabActive].tl,
        totalPrice: loan['s'][this.tabActive].totalPrice,
        interestTotal: loan['s'][this.tabActive].interestTotal,
      };

      this.a = {
        e_money: loan['a'][this.tabActive]['list'][0].everyMonthPrice,
        loanTotalPrice: loan['a'][this.tabActive].loanTotalPrice,
        tl: loan['a'][this.tabActive].tl,
        totalPrice: loan['a'][this.tabActive].totalPrice,
        interestTotal: loan['a'][this.tabActive].interestTotal,
      };
    }
  },
});
